#ifndef PATH5C_H_
#define PATH5C_H_

#include "precom.h"
#include <list>

struct Path5CPoint {
	fmath::vector3 m_point;
	fmath::vector2 m_eulerAngles;

	Path5CPoint();

	bool operator ==(const Path5CPoint& p) const
	{
		return (
			(m_point - p.m_point).length() < 10.f * EPS
			&& (m_eulerAngles - p.m_eulerAngles).length() < 10.f * EPS
			);
	}

	Path5CPoint& operator=(const Path5CPoint& p)
	{
		if(&p == this) return *this;
		m_point = p.m_point;
		m_eulerAngles = p.m_eulerAngles;
		return *this;
	}
};

class Path5C 
{
private:
	std::list<Path5CPoint> m_path;
	std::list<Path5CPoint>::const_iterator m_next;
	Path5CPoint m_current, m_prev, m_prevCurrent;
protected:
	int CalculateNextPoint(const Path5CPoint& a_curPos, float& a_distance);
public:
	Path5C();
	Path5C(wchar_t* a_fileName);
	~Path5C();

	int LoadFromFile(wchar_t* a_fileName);
	int SaveToFile(wchar_t* a_fileName);
	int TakeStep(const Path5CPoint& a_curPos, float a_distance);
	int ResetSteps();
	void ClearPath();
	void SkipPoint();
	
	inline bool IsEmpty() const {return m_path.empty(); }
	inline unsigned int Size() const { return m_path.size(); }	
	inline void Add5CPoint(const Path5CPoint& a_point) { m_path.push_back(a_point); }	
	inline std::list<Path5CPoint>::const_iterator GetBeginIter() const { return m_path.begin(); }
	inline std::list<Path5CPoint>::const_iterator GetEndIter() const { return m_path.end(); }
	inline const Path5CPoint& GetCurrrentPoint() const
	{ return m_current; }
};

#endif //PATH5C_H_